-
Notifications
You must be signed in to change notification settings - Fork 0
feat: Add displaying the country depending on the IP #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
feat: Add displaying the country depending on the IP #8
Conversation
index.ts
Outdated
| return rows[0][countryCol]; | ||
| } | ||
| } | ||
| } catch (e) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add something to catch
index.ts
Outdated
|
|
||
| { insecureRawSQL: `"${countryCol}" IS NOT NULL` } | ||
| ] | ||
| }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yaroslav8765 could you please use Filters.AND Filters.EQ and so on, instead of row notation used by Oleksander. Also could we add another filters operations Filters.IsEmpty(field) and Filters.isNotEmpty(field) - for sql databses IsEmpty is IS NULL, and isNotEmpty IS NOT NULL. For mongo it check against undefined
index.ts
Outdated
|
|
||
| // API Request | ||
| try { | ||
| const apiUrl = `https://geoip.vuiz.net/geoip?ip=${clientIp}`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
vuiz sounds like something unknown without defined limints, please lets use something more reliable with strict policy, e.g.
curl https://ipinfo.io/8.8.8.8/json
| }, {}); | ||
|
|
||
| // Cloudflare Check (Fastest) | ||
| const cfCountry = headersLower['cf-ipcountry']; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yaroslav8765 move 'cf-ipcountry' to plugin options and mention in docs. Name:
// should be in format ISO 3166-1 alpha-2
// e.g. for ckloudflare it should be 'CF-IPCountry'
isoCountryCodeRequestHeader: string
| return cfCountry.toUpperCase(); | ||
| } | ||
|
|
||
| if (!clientIp || clientIp === '127.0.0.1' || clientIp === '::1' || clientIp.includes('localhost')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not needed because getClinetIp (Af internal) already should return null for any private CIDR
No description provided.